package com.open.source.rabbit.provider;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zhanglong and since on 2020/3/26 9:16 下午
 */
@RestController
@RequestMapping("/rabbit/provider")
public class ProviderController {

    @Resource
    private RabbitTemplate rabbitTemplate;


    @GetMapping("/direct/publish/{msgTimes}")
    public void publishMessage(@PathVariable Integer msgTimes) {
        for (int i = 0; i <= msgTimes; i++) {
            rabbitTemplate.convertAndSend("direct", "direct_routing_key", "direct to zen long");
        }
    }
}
